#include "matrixfunctions.h"

int sumofmatrix(int x[][100], int rows, int col)
{
	int sum=0, max=x[0][0];
	int i, j;
	for (i=0;i<rows;i++)
		for(j=0;j<col;j++){
			sum+= x[i][j];
			if(max<x[i][j])
				max=x[i][j];
		}
return sum;
}

int maxofmatrix(int x[][100],int rows, int col, int *posi, int *posj)
{
	int max=x[0][0];
	int i, j;
	for (i=0;i<rows;i++)
		for(j=0;j<col;j++)
			if(max<x[i][j]){
				max=x[i][j];
				*posi=i;
				*posj=j;
			}
return max;
}

int main()
{
	int row, col, sum, max, posi, posj;
	int mat[100][100];
	cout<<"Number of rows : " ;
	cin>>row;
	cout<<"Number of columns : " ;
	cin>>col;
	readmatrix(mat, row, col);
	sum=sumofmatrix(mat, row, col);
	max=maxofmatrix(mat, row, col, &posi, &posj);
	cout<<sum<<"\n";
	cout<<"MAX : " << max <<" on " <<posi<<" " <<posj<<"\n";


return 0;
}
